/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import dao.ProjetoDAO;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.swing.table.DefaultTableModel;
import model.Login;
import model.Projeto;

/**
 *
 * @author JONATAS
 */
public class TelaInicialFrame extends javax.swing.JFrame {

    /**
     * Creates new form TelaInicialFrame
     */
    public TelaInicialFrame() {
        initComponents();        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        tbCliente = new javax.swing.JButton();
        tbMateriais = new javax.swing.JButton();
        tbProjeto = new javax.swing.JButton();
        tbConsultarProjeto = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        lbUsuarioLogado = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        mitUsuarios = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JPopupMenu.Separator();
        mitClasses = new javax.swing.JMenuItem();
        mitFamilias = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();
        mitUnidade = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        jMenuItem9 = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem5 = new javax.swing.JMenuItem();
        mitConsultarProjeto = new javax.swing.JMenuItem();
        jMenuItem10 = new javax.swing.JMenuItem();
        Relatório = new javax.swing.JMenu();
        jMenuItem14 = new javax.swing.JMenuItem();
        jMenuItem15 = new javax.swing.JMenuItem();
        jMenuItem16 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem7 = new javax.swing.JMenuItem();

        jLabel2.setText("jLabel2");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Agropampa");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });
        addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                formFocusGained(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "ID Projeto", "Cliente", "Descrição", "Data Limite", "Endereço", "Situação"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(0).setMinWidth(80);
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(80);
        jTable1.getColumnModel().getColumn(0).setMaxWidth(80);
        jTable1.getColumnModel().getColumn(3).setMinWidth(85);
        jTable1.getColumnModel().getColumn(3).setPreferredWidth(85);
        jTable1.getColumnModel().getColumn(3).setMaxWidth(85);
        jTable1.getColumnModel().getColumn(5).setMinWidth(100);
        jTable1.getColumnModel().getColumn(5).setPreferredWidth(100);
        jTable1.getColumnModel().getColumn(5).setMaxWidth(100);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 489, Short.MAX_VALUE)
                .addContainerGap())
        );

        jLabel3.setText("Agenda:");

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        tbCliente.setIcon(new javax.swing.ImageIcon("C:\\SVN2\\CODIGO\\icons\\icon_clientes1.gif")); // NOI18N
        tbCliente.setText("Cadastro de Clientes");
        tbCliente.setMaximumSize(new java.awt.Dimension(205, 60));
        tbCliente.setMinimumSize(new java.awt.Dimension(205, 60));
        tbCliente.setPreferredSize(new java.awt.Dimension(205, 60));
        tbCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbClienteActionPerformed(evt);
            }
        });

        tbMateriais.setIcon(new javax.swing.ImageIcon("C:\\SVN2\\CODIGO\\icons\\tijolo001_1.gif")); // NOI18N
        tbMateriais.setText("Cadastro de Materiais");
        tbMateriais.setMaximumSize(new java.awt.Dimension(211, 60));
        tbMateriais.setMinimumSize(new java.awt.Dimension(211, 60));
        tbMateriais.setPreferredSize(new java.awt.Dimension(211, 60));
        tbMateriais.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbMateriaisActionPerformed(evt);
            }
        });

        tbProjeto.setIcon(new javax.swing.ImageIcon("C:\\SVN2\\CODIGO\\icons\\checklist_247w_1_.gif")); // NOI18N
        tbProjeto.setText("Inclusão de projeto");
        tbProjeto.setMaximumSize(new java.awt.Dimension(197, 60));
        tbProjeto.setMinimumSize(new java.awt.Dimension(197, 60));
        tbProjeto.setPreferredSize(new java.awt.Dimension(197, 60));
        tbProjeto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbProjetoActionPerformed(evt);
            }
        });

        tbConsultarProjeto.setIcon(new javax.swing.ImageIcon("C:\\SVN2\\CODIGO\\icons\\lupa_1.gif")); // NOI18N
        tbConsultarProjeto.setText("Consultar Projeto");
        tbConsultarProjeto.setMaximumSize(new java.awt.Dimension(185, 60));
        tbConsultarProjeto.setMinimumSize(new java.awt.Dimension(185, 60));
        tbConsultarProjeto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbConsultarProjetoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tbCliente, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tbMateriais, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tbProjeto, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tbConsultarProjeto, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tbCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tbMateriais, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tbProjeto, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tbConsultarProjeto, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel4.setText("Atalhos:");

        lbUsuarioLogado.setText("jLabel1");

        jMenu1.setText("Cadastros");

        jMenuItem1.setText("Clientes");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        mitUsuarios.setText("Usuários");
        mitUsuarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mitUsuariosActionPerformed(evt);
            }
        });
        jMenu1.add(mitUsuarios);
        jMenu1.add(jSeparator3);

        mitClasses.setText("Classes");
        mitClasses.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mitClassesActionPerformed(evt);
            }
        });
        jMenu1.add(mitClasses);

        mitFamilias.setText("Famílias");
        mitFamilias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mitFamiliasActionPerformed(evt);
            }
        });
        jMenu1.add(mitFamilias);

        jMenuItem8.setText("Produtos");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem8);

        mitUnidade.setText("Unidade de Medida");
        mitUnidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mitUnidadeActionPerformed(evt);
            }
        });
        jMenu1.add(mitUnidade);
        jMenu1.add(jSeparator1);

        jMenuItem9.setText("Localização");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem9);
        jMenu1.add(jSeparator2);

        jMenuItem4.setText("Sair");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem4);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Projetos");

        jMenuItem5.setText("Gerenciar Projetos");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem5);

        mitConsultarProjeto.setText("Consultar Projetos");
        mitConsultarProjeto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mitConsultarProjetoActionPerformed(evt);
            }
        });
        jMenu2.add(mitConsultarProjeto);

        jMenuItem10.setText("Imprimir Documento");
        jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem10ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem10);

        jMenuBar1.add(jMenu2);

        Relatório.setText("Relatórios");

        jMenuItem14.setText("Relatório de Materiais");
        jMenuItem14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem14ActionPerformed(evt);
            }
        });
        Relatório.add(jMenuItem14);

        jMenuItem15.setText("Relatório de Projetos");
        jMenuItem15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem15ActionPerformed(evt);
            }
        });
        Relatório.add(jMenuItem15);

        jMenuItem16.setText("Relatório de Clientes");
        jMenuItem16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem16ActionPerformed(evt);
            }
        });
        Relatório.add(jMenuItem16);

        jMenuBar1.add(Relatório);

        jMenu4.setText("Sobre");
        jMenuBar1.add(jMenu4);

        jMenu3.setText("Sair");

        jMenuItem2.setText("Trocar usuário");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem2);

        jMenuItem7.setText("Sair");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem7);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lbUsuarioLogado)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addComponent(jLabel4))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(lbUsuarioLogado)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-1103)/2, (screenSize.height-765)/2, 1103, 765);
    }// </editor-fold>//GEN-END:initComponents

    private void buscarDados() {
        
        Date d = new Date();        
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat sdf2 = new SimpleDateFormat("dd/MM/yyyy");
        System.out.println(sdf.format(new Date()));        
        
        System.out.println("buscando dados");
        sdf.format(new Date());
        // List<Projeto> lista = prodao.findCustomizado( " pro_dataFimPrevista <= cast('"+ sdf.format(new Date())+"' as date) + 30 "+" and pro_status in (0,1) order by pro_dataFimPrevista ");
        prodao = new ProjetoDAO();
        List<Projeto> lista = prodao.findCustomizado( " pro_status in (0,1) order by pro_dataFimPrevista ");
        
        DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();
        modelo.setNumRows(0);
        
        int i = 0;
        for (Projeto m : lista) {
            
            situacao = "Erro";
            System.out.println("situacao = "+m.getPro_status());
            switch (m.getPro_status()) {
                case -1:
                    situacao = "Excluído";
                    break;
                case 0:
                    situacao = "Aberto";
                    break;
                case 1:
                    situacao = "Em construção";
                    break;
                case 2:
                    situacao = "Concluído";
                    break;
            }
            modelo.addRow(new String[]{"" + m.getPro_id(), "" + m.getCliente().getNomeCompleto(), m.getPro_descricao(), sdf2.format(m.getPro_dataFimPrevista()), m.getEnderecoInst(), situacao});
            jTable1.setModel(modelo);
        }
    }
    
    private void zerar(){
     DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();
        modelo.setNumRows(0);
    }
    
    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        ClienteFrame cf = new ClienteFrame();
        cf.setVisible(true);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void mitUsuariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitUsuariosActionPerformed
        UsuarioFrame cf = new UsuarioFrame();
        cf.setVisible(true);
    }//GEN-LAST:event_mitUsuariosActionPerformed

    private void mitClassesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitClassesActionPerformed
        ClasseFrame cf = new ClasseFrame();
        cf.setVisible(true);
    }//GEN-LAST:event_mitClassesActionPerformed

    private void mitFamiliasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitFamiliasActionPerformed
        FamiliaFrame cf = new FamiliaFrame();
        cf.setVisible(true);
    }//GEN-LAST:event_mitFamiliasActionPerformed

    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
        MaterialFrameTab1 cf = new MaterialFrameTab1();
        cf.setVisible(true);
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
        LocalizaFrame cf = new LocalizaFrame();
        cf.setVisible(true);
    }//GEN-LAST:event_jMenuItem9ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        System.exit(1);
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        ProjetoFrame cf = new ProjetoFrame();
        cf.setVisible(true);
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void mitConsultarProjetoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitConsultarProjetoActionPerformed
       
   }//GEN-LAST:event_mitConsultarProjetoActionPerformed

    private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
        System.exit(1);
    }//GEN-LAST:event_jMenuItem7ActionPerformed

    private void tbProjetoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbProjetoActionPerformed
        ProjetoFrame cf = new ProjetoFrame();
        cf.setVisible(true);
    }//GEN-LAST:event_tbProjetoActionPerformed

    private void tbMateriaisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbMateriaisActionPerformed
        MaterialFrameTab1 cf = new MaterialFrameTab1();
        cf.setVisible(true);     
    }//GEN-LAST:event_tbMateriaisActionPerformed

    private void tbClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbClienteActionPerformed
        ClienteFrame cf = new ClienteFrame();
        cf.setVisible(true);
    }//GEN-LAST:event_tbClienteActionPerformed

    private void tbConsultarProjetoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbConsultarProjetoActionPerformed
        ProjetoDialog cf = new ProjetoDialog(null, true);
        cf.setVisible(true);
    }//GEN-LAST:event_tbConsultarProjetoActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        buscarDados();
        carregaMenu();
    }//GEN-LAST:event_formWindowOpened

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
        System.out.println("Buscar dados");
        zerar();
        buscarDados();
        
        
    }//GEN-LAST:event_formWindowActivated

    private void jMenuItem14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem14ActionPerformed
        MaterialDialog md = new MaterialDialog(null, true);
        md.setVisible(true);
    }//GEN-LAST:event_jMenuItem14ActionPerformed

    private void jMenuItem15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem15ActionPerformed
        ProjetoDialog md = new ProjetoDialog(null, true);
        md.setVisible(true);
    }//GEN-LAST:event_jMenuItem15ActionPerformed

    private void jMenuItem16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem16ActionPerformed
        ClientesDialog md = new ClientesDialog(null, true);
        md.setVisible(true);
    }//GEN-LAST:event_jMenuItem16ActionPerformed

    private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem10ActionPerformed
        ProjetoFrame cf = new ProjetoFrame();
        cf.setVisible(true);
    }//GEN-LAST:event_jMenuItem10ActionPerformed

    private void formFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_formFocusGained
        buscarDados();
        System.out.println("BUSCAR DADOS");
    }//GEN-LAST:event_formFocusGained

    private void mitUnidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mitUnidadeActionPerformed
        UnidadeMedidaFrame um = new UnidadeMedidaFrame();
        um.setVisible(true);
    }//GEN-LAST:event_mitUnidadeActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        LoginFrame lf = new LoginFrame();
        lf.setVisible(true);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void carregaMenu(){
        lbUsuarioLogado.setText("Usuário Logado: "+ Login.getNome());
        switch(Login.getNivelAcesso())
        {
            case 1: 
                mitClasses.setEnabled(false);
                mitFamilias.setEnabled(false);
                mitUsuarios.setEnabled(false);
                break;
        }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TelaInicialFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TelaInicialFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TelaInicialFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TelaInicialFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new TelaInicialFrame().setVisible(true);
            }
        });
    }
    private String SQL;
    private String situacao;
    private Projeto pro = new Projeto();
    private ProjetoDAO prodao = new ProjetoDAO();
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu Relatório;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem14;
    private javax.swing.JMenuItem jMenuItem15;
    private javax.swing.JMenuItem jMenuItem16;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JPopupMenu.Separator jSeparator3;
    private javax.swing.JTable jTable1;
    private javax.swing.JLabel lbUsuarioLogado;
    private javax.swing.JMenuItem mitClasses;
    private javax.swing.JMenuItem mitConsultarProjeto;
    private javax.swing.JMenuItem mitFamilias;
    private javax.swing.JMenuItem mitUnidade;
    private javax.swing.JMenuItem mitUsuarios;
    private javax.swing.JButton tbCliente;
    private javax.swing.JButton tbConsultarProjeto;
    private javax.swing.JButton tbMateriais;
    private javax.swing.JButton tbProjeto;
    // End of variables declaration//GEN-END:variables
}
